<template>
  <div>
    <div>
      <Form ref="formInline" :model="formInline">
        <Row justify="space-between">
          <Col span="6">
            <FormItem prop="oid">
              <Input type="text" v-model="formInline.oid" placeholder="订单号">
                <Icon type="ios-person-outline" slot="prepend"></Icon>
              </Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem prop="cname">
              <Input
                type="text"
                v-model="formInline.cname"
                placeholder="客户姓名"
              >
                <Icon type="md-cube" slot="prepend" />
              </Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem prop="batch">
              <Select
                v-model="formInline.batch"
                clearable
                filterable
                placeholder="批次"
              >
                <Option
                  v-for="(item, index) in batchs"
                  :value="item.value"
                  :key="index"
                  >{{ item.label }}</Option
                >
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row justify="space-between">
          <Col span="6">
            <FormItem  prop="sname">
              <Select
                v-model="formInline.sname"
                clearable
                filterable
                placeholder="选择仓库编号"
              >
                <Option
                  v-for="(item, index) in stores.snames"
                  :value="item.value"
                  :key="index"
                  >{{ item.label }}</Option
                >
              </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem  prop="cropname">
              <Select
                v-model="formInline.cropname"
                clearable
                placeholder="选择作物名称"
                filterable
              >
                <Option
                  v-for="(item, index) in crops.names"
                  :value="item.value"
                  :key="index"
                  >{{ item.label }}</Option
                >
              </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem>
              <Button type="primary" @click="handleSubmit('formInline')"
                >搜索</Button
              >
              <Button type="primary" style="margin-left: 8px" @click="to"
                >添加</Button
              >
              <!-- <Button style="margin-left: 8px" @click="handleBack">返回</Button> -->
            </FormItem>
          </Col>
        </Row>
      </Form>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      flag: true,
      stores:{},
      crops:{},
      batchs:[],
      formInline: {
        oid: "",
        cname: "",
        batch: "",
        sname: "",
        cropname: "",
      },
    };
  },
  mounted() {
    this.axios
      .get("/api/sc")
      .then((r) => {
        this.stores = r.data.stores;
        this.crops = r.data.crops;
        this.batchs = r.data.batches;
        this.loading = false;
      })
      .catch((e) => {
        this.$Message.error("E" + e);
      });
  },
  methods: {
    handleSubmit() {
      this.$emit("search",this.formInline)
      
    },
    to() {
      this.$router.push({ path: "/sale/add" });
    },
  },
};
</script>
